/*
 * @ddescription: 订单备注弹窗
 * @Author: along
 * @Date: 2020-12-11
 * @Last Modified by: along
 * @Last Modified time: 2020-12-11
 */
<template>
    <div class="setOrderRemark">
        <el-dialog
            title="设置备注"
            :visible.sync="dialogLog"
            width="640px"
            :close-on-click-modal="false"
        >
            <el-input
                type="textarea"
                :autosize="{ minRows: 4, maxRows: 6}"
                placeholder="请输入备注"
                v-model="remark"
                :style="{marginBottom: '32px'}"
            />
            <div
                slot="footer"
                class="dialog-footer"
            >
                <el-button
                    @click="dialogLog = false"
                    size="medium"
                    type="default"
                    :style="{width: '120px', marginRight: '32px'}"
                >
                    取 消
                </el-button>
                <el-button
                    type="primary"
                    size="medium"
                    :style="{width: '120px'}"
                    @click="submit()"
                    :disabled="!remark"
                >
                    确 认
                </el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
export default {
    name: 'SetOrderRemark',
    data () {
        return {
            dialogLog: false,
            remark: '',
            order_no: ''
        };
    },
    watch: {
        dialogLog (val) {
            if(!val) {
                this.remark = '';
            }
        }
    },
    mounted () {
    },
    methods: {
        /**
         * @description 打开弹窗
         */
        show (order_no) {
            this.dialogLog = true;
            this.order_no = order_no;
        },

        /**
         * @description 关闭弹窗
         */
        close () {
            this.dialogLog = false;
        },

        /**
         * @description 确认修改收货地址
         */
        submit (formName) {
            this.$post('/__student/ShopGoodsOrder/setRemark', {
                order_no: this.order_no,
                remark: this.remark
            }).then(resp => {
                if (resp.code == 1) {
                    this.$emit('update');
                    this.dialogLog = false;
                    this.$notify({
                        title: '提示',
                        message: '设置成功',
                        duration: 2000,
                        type: 'success'
                    });
                } else {
                    this.$notify({
                        title: '警告',
                        message: resp.msg,
                        duration: 2000,
                        type: 'warning'
                    });
                }
            });
        }
    }
};
</script>

<style lang="less" scoped>
.setOrderRemark {
    .dialog-footer {
        display: flex;
        justify-content: center;
    }
}
</style>

<style lang="less">
.setOrderRemark {
    .el-dialog__body {
        padding-bottom: 0px;
    }
    .el-dialog__footer {
        padding-top: 0;
        padding-bottom: 36px;
    }
}
</style>